package com.ktjy.ktmall.service.impl;

import com.ktjy.ktmall.dao.UserDao;
import com.ktjy.ktmall.dao.impl.UserDaoImp;
import com.ktjy.ktmall.entity.User;
import com.ktjy.ktmall.service.UserService;

import java.util.Collections;
import java.util.List;

public class UserServiceImpl implements UserService {

    UserDao userDao = new UserDaoImp();

    @Override
    public int insertUser(User user) {
        return userDao.insertUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int deleteUser(User user) {
        return userDao.deleteUser(user);
    }

    @Override
    public User selectUserById(int id) {
        return userDao.selectUserById(id);
    }

    @Override
    public List<User> selectUserList() {
        return userDao.selectUserList();
    }

    /**
     * @param currPageNo 起始位置偏移量
     * @param pageSize   每页显示的数据行数
     * @return
     */
    @Override
    public List<User> getUserListPage(Integer currPageNo, Integer pageSize) {
        Integer from = (currPageNo - 1) * pageSize;
        return userDao.getGoodsListPage(from, pageSize);
    }

    @Override
    public int getCount() {
        return userDao.count();
    }


    public User login(User user) {
        return userDao.login(user);
    }
}
